﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="user.ascx.cs" Inherits="RegisterUser" %>
<script language="javascript" >
    function testRePass()
    {
        var RePass =  document.getElementById("ctl00_mainHolder_Register1_tb_Repassword");
        var Pass =  document.getElementById("ctl00_mainHolder_Register1_tb_Password");
        var validRepass = document.getElementById("valid_repass");
        var btnSub = document.getElementById("ctl00_mainHolder_Register1_btn_Registr");
        if((RePass.value != Pass.value) || (RePass.value.length < 5) || (Pass.value.length < 5))
        {
            validRepass.style.color = "Red";
            btnSub.disabled = "disabled";
        }
        else
        {   
            validRepass.style.color = "Green";
            btnSub.disabled = "";
        }
    }
    
    var xmlHttp;       
    function createXMLHttpRequest()
    {
        if (window.ActiveXObject)
        {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else if (window.XMLHttpRequest)
        {
            xmlHttp = new XMLHttpRequest();
        }
    }    
    
    function CheckLogin(arg)
    {
        var str = "" + arg.value;
        var el = document.getElementById('span_Login');
        if(str.length < 5)
        {
            el.style.color = "#F00";
            el.innerHTML = "";
        }
        else
        {
            el.innerHTML = "";
            createXMLHttpRequest();
            xmlHttp.onreadystatechange = handleStateChange;      
            xmlHttp.open("POST", "../Modules/UserManager/Register/CheckLogin.ashx", true);
            xmlHttp.send(str);
        }
    }
    function handleStateChange()
    {
        if(xmlHttp.readyState == 4)
        {
            if(xmlHttp.status == 200)
            {
                getContext(xmlHttp.responseText);
            }
        }
    }
    
    function getContext(arg2)
    {
        var el = document.getElementById('span_Login');
        switch(arg2)
        {
            case "ok":
            {
                el.style.color = "#0A0";
                el.innerHTML = "";
                break;
            }
            
            case "bad":
            {
                el.style.color = "#F00";
                el.innerHTML = "Пользователь с таким email уже есть";
                break;
            }
        }    
    }
</script>


<table class="tbl" id="tbl_register" runat="server">
        <tr>
            <td colspan="2" style="padding: 2px;  color: #000; font-size: 100%;"><asp:Label ID="lb_0001" runat="server" Text="Новый пользователь" /></td>
        </tr>
<tr>
    <td class="um_cell" align="right"><strong>E-mail</strong>&nbsp;*</td>
    <td class="um_cell2">
        <asp:TextBox ID="tb_Email" onkeyup="CheckLogin(this);" CssClass="um_textb" runat="server" />
        <span id="span_Login"></span>
    </td>
</tr>
<tr>
    <td class="um_cell" align="right"><strong>Пароль</strong>&nbsp;*</td>
    <td class="um_cell2"><asp:TextBox TextMode="Password" ID="tb_Password" runat="server" onchange="testRePass();" CssClass="um_textb" /><p style="font-size: 10px;">минимум 6 символов</p></td>
</tr>
<tr>
    <td class="um_cell" align="right"><strong>Подтвердите пароль</strong>&nbsp;**</td>
    <td class="um_cell2"><asp:TextBox TextMode="Password" ID="tb_Repassword" runat="server" onchange="testRePass();" CssClass="um_textb" /><span id="valid_repass" style="font-weight:bold; color: Red;">&nbsp;!&nbsp;</span></td>
</tr>
<tr>
    <td class="um_cell" align="right"><strong>Имя</strong>&nbsp;*</td>
    <td class="um_cell2"><asp:TextBox ID="tb_Name" CssClass="um_textb" runat="server" /></td>
</tr>
<tr>
    <td class="um_cell" align="right"><strong>Фамилия</strong>&nbsp;*</td>
    <td class="um_cell2"><asp:TextBox ID="tb_Fname" CssClass="um_textb" runat="server" /></td>
</tr>
<tr>
    <td class="um_cell" align="right">Страна&nbsp;</td>
    <td class="um_cell2">
        <asp:DropDownList ID="ddl_country" Width="150" runat="server" >
        </asp:DropDownList>
    </td>
</tr>
<tr>
    <td class="um_cell" align="right">Город&nbsp;</td>
    <td class="um_cell2">
        <asp:TextBox ID="tb_City" CssClass="um_textb" runat="server" />
    </td>
</tr>
<tr>
    <td class="um_cell" align="right">Должность&nbsp;</td>
    <td class="um_cell2">
        <asp:DropDownList ID="ddl_Roles" runat="server" Width="150" />
    </td>
</tr>
<tr>
    <td class="um_cell" align="right">Фото&nbsp;</td>
    <td class="um_cell2">
        <asp:Image ID="img_Photo" runat="server" Visible="false" /><br />
        <asp:FileUpload ID="fu_Photo" runat="server" />
    </td>
</tr>
<tr>
    <td class="um_cell" align="right">Телефон &nbsp;</td>
    <td class="um_cell2">
        <asp:TextBox ID="tb_Phone" CssClass="um_textb" runat="server" />
    </td>
</tr>
<tr>
    <td>
    </td>
    <td style="padding: 5px;">
        <asp:Button id="btn_Registr" Text="Регистрация" OnClick="SendRegisterRequest" CssClass="btn" Enabled="false" runat="server" />
        <asp:Button id="btn_Edit" Text="Сохранить" Visible="false" OnClick="Edit" CssClass="btn" runat="server" />
    </td>
</tr>
<tr>
    <td colspan="2" align="center">
        <div id="ValidBlock" style="color: Red;" runat="server">
        </div>
    </td>
</tr>
</table>
<div align="center">
    <asp:Label ID="lb_Activation" runat="server" />
</div>


